import type { NextConfig } from "next";

// 后端 API 基地址（可通过环境变量覆盖）
const API_BASE = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.zhihunyun.xyz";

const nextConfig: NextConfig = {
	reactStrictMode: false, // 临时禁用严格模式来解决hooks问题
	async rewrites() {
		return [
			// 统一将 H5 的 /v1/** 代理到后端 API，避免直接命中 Next 导致返回 HTML
			{ source: "/v1/:path*", destination: `${API_BASE}/v1/:path*` },
			// 静态与上传资源代理，供管理端预览
			{ source: "/static/:path*", destination: `${API_BASE}/static/:path*` },
			{ source: "/uploads/:path*", destination: `${API_BASE}/uploads/:path*` },
			// 兼容原有人脸接口示例
			{ source: "/face/:path*", destination: `${API_BASE}/api/ai/face/:path*` },
		];
	},
};

export default nextConfig;
